<template>
  <div class="MedicineAdd">
    <van-nav-bar title="添加药品" left-text="返回" left-arrow @click-left="router.back()" />
    
    <van-form @submit="onSubmit">
      <van-field v-model="form.name" label="药品名称" placeholder="请输入药品名称" required />

      <van-field v-model="form.manufacturer" label="制药公司" placeholder="请输入制药公司" />

      <van-field v-model="form.expiryDate" label="有效期" placeholder="请输入有效期" required />

      <van-field v-model="form.type" label="类型" placeholder="请输入类型（中药、西药、雾化...）" required />

      <van-field v-model="form.details" label="详情" placeholder="请输入详情" />

      <van-field v-model="form.dosage" label="一盒的量（数）" placeholder="请输入一盒的量" required />

      <van-field v-model="form.unit" label="单位" placeholder="请输入单位" required />

      <van-field v-model="form.medicationInfo" label="用药信息" placeholder='请输入用药信息，格式：{"before": 3600, "after": 1800}' />

      <van-field v-model="form.recommendedUsage" label="推荐用药数据" placeholder='请输入推荐用药数据，格式：{"day": 1, "times": 3, "amount": 2}' />

      <van-button round native-type="submit">提交</van-button>
    </van-form>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import { Toast } from 'vant'

const router = useRouter()

const form = ref({
  name: '',
  manufacturer: '',
  expiryDate: '',
  type: '',
  details: '',
  dosage: '',
  unit: '',
  medicationInfo: '',
  recommendedUsage: ''
})

const onSubmit = () => {
  // 这里可以添加提交表单的逻辑，例如发送请求到后端
  Toast.success('提交成功')
  router.back()
}
</script>

<style scoped>
</style>
